package com.cf.base.http.generator;

import com.cf.base.http.core.RetrofitService;

import java.lang.reflect.Method;

/**
 * @author yangji
 */
public class GeneratorMethod {
    public static <T> T generator(RetrofitService bean, Method method, Throwable throwable) {
        IErrorAdapter adapter = bean.getAdapter();
        if (adapter == null) {
            //没有配置 错误解析器
            throw new NullPointerException("未配置 错误解析器");
        }
        return adapter.call(bean, method, throwable);
    }


    public static Throwable generatorError(RetrofitService bean, Method method, Throwable throwable) {
        BaseBodyErrorAdapter adapter = (BaseBodyErrorAdapter) bean.getAdapter();
        if (adapter == null) {
            //没有配置 错误解析器
            throw new NullPointerException("未配置 错误解析器");
        }
        return adapter.call(bean, method, throwable);
    }
}
